Fix an issue of deadlock in Cargo
authorAlex Crichton <alex@alexcrichton.com>
Sat, 26 May 2018 02:12:53 +0000 (19:12 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Sat, 26 May 2018 02:12:53 +0000 (19:12 -0700)
commit1868998bec6a311d2dd8e4549968df58d1b787ab
tree9c2aba3f8d8847b15b0274d7552e1100da38d608
parent4c8b8ac1e7f2adf16bd90fa6da2b6a21f8e6cd4c
Fix an issue of deadlock in Cargo

Currently Cargo can deadlock itself via file locks in somewhat obscure
scenarios. One way to trigger this scenario is by causing the index to fail
being created, for example through an invalid `init.templatedir` configuration.

This commit takes the strategy of solving two bugs:

* First, the deadlock is fixed. This is done by manually ensuring that the
  current deadlock doesn't happen by scheduling cached work to happen outside
  the scope of a lock.
* Second, the initialization of the registry's index is fixed. We turn off the
  usage of external templates as we don't want to use them for this internally
  managed repository anyway.

Closes #5551
src/cargo/core/registry.rs
src/cargo/sources/registry/index.rs
src/cargo/sources/registry/local.rs
src/cargo/sources/registry/mod.rs
src/cargo/sources/registry/remote.rs
src/cargo/util/errors.rs
tests/testsuite/registry.rs